package dao;
//2
import model.Classes;
import utils.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Collection;

public class ClassDao {
    public int insert(Classes record){
        Connection connection=null;
        PreparedStatement statement=null;

        try {
            connection= DBUtil.getConnection();
            String sql="insert into class (name) values (?)";
            statement=connection.prepareStatement(sql);
            statement.setString(1, record.getName());
            int i = statement.executeUpdate();
            return i;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            DBUtil.close(null,statement,connection);
        }
    }
}
